package cn.tedu._05mvcboot04.response;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class JsonResult {
    private Integer state;
    private String massage;
    private Object data;

    public JsonResult(StatusCode statusCode){
        this.state=statusCode.getState();
        this.massage=statusCode.getMassage();
    }
    public JsonResult(StatusCode statusCode,Object data){
        this.state=statusCode.getState();
        this.massage=statusCode.getMassage();
        this.data=data;
    }

    //操作成功
    public static JsonResult ok(Object data){
        return new JsonResult(StatusCode.OPERATION_FAILED,data);
    }
    public static JsonResult ok(){
        return JsonResult.ok(null);
    }
}
